home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Jotto2.so Folder / Jotto ][ ƒ / Wipes, etc. / Mr. Do.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-02  |  4.2 KB  |  193 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. Jotto ][ -=- a simple word game, revisited
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30. #include "wipe dispatch.h"
  31.  
  32. #define        BoxSize    4
  33. #define CorrectTime 1
  34.  
  35. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern
  36.    and alternatively scroll it up or down. */
  37.    
  38. void MrDo(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, short theWindowHeight, short theWindowWidth)
  39. {
  40.     short            x, y;
  41.     short            vgap,hgap;
  42.     Rect        theRect, dest;
  43.     Rect        scrollsource, scrolldest;
  44.     Rect        bounds[25];
  45.     Boolean        everyOther;
  46.     
  47.     vgap=theWindowHeight/5;
  48.     hgap=theWindowWidth/5;
  49.     
  50.     for (x=0; x<25; x++)
  51.     {
  52.         switch (x)
  53.         {
  54.             case 0:
  55.             case 1:
  56.             case 2:
  57.             case 3:
  58.             case 4:
  59.                 bounds[x].top=0;
  60.                 break;
  61.             case 15:
  62.             case 16:
  63.             case 17:
  64.             case 18:
  65.             case 5:
  66.                 bounds[x].top=vgap;
  67.                 break;
  68.             case 14:
  69.             case 23:
  70.             case 24:
  71.             case 19:
  72.             case 6:
  73.                 bounds[x].top=vgap*2;
  74.                 break;
  75.             case 13:
  76.             case 22:
  77.             case 21:
  78.             case 20:
  79.             case 7:
  80.                 bounds[x].top=vgap*3;
  81.                 break;
  82.             case 12:
  83.             case 11:
  84.             case 10:
  85.             case 9:
  86.             case 8:
  87.                 bounds[x].top=vgap*4;
  88.                 break;
  89.         }
  90.         switch (x)
  91.         {
  92.             case 0:
  93.             case 15:
  94.             case 14:
  95.             case 13:
  96.             case 12:
  97.                 bounds[x].left=0;
  98.                 break;
  99.             case 1:
  100.             case 16:
  101.             case 23:
  102.             case 22:
  103.             case 11:
  104.                 bounds[x].left=hgap;
  105.                 break;
  106.             case 2:
  107.             case 17:
  108.             case 24:
  109.             case 21:
  110.             case 10:
  111.                 bounds[x].left=hgap*2;
  112.                 break;
  113.             case 3:
  114.             case 18:
  115.             case 19:
  116.             case 20:
  117.             case 9:
  118.                 bounds[x].left=hgap*3;
  119.                 break;
  120.             case 4:
  121.             case 5:
  122.             case 6:
  123.             case 7:
  124.             case 8:
  125.                 bounds[x].left=hgap*4;
  126.                 break;
  127.         }
  128.         bounds[x].bottom=bounds[x].top+vgap;
  129.         bounds[x].right=bounds[x].left+hgap;
  130.     }
  131.     
  132.     for (y=0; y<25; y++)
  133.     {        
  134.         if (y%2)   /* these scroll up */
  135.         {
  136.             scrollsource=bounds[y];
  137.             scrollsource.top+=BoxSize;
  138.             scrolldest=scrollsource;
  139.             OffsetRect(&scrolldest,0,-BoxSize);
  140.             
  141.             dest=bounds[y];
  142.             dest.top=dest.bottom-BoxSize;
  143.             
  144.             theRect=bounds[y];
  145.             theRect.bottom=theRect.top+BoxSize;
  146.             
  147.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  148.             {
  149.                 StartTiming();
  150.                 CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  151.                         &scrollsource, &scrolldest, 0, 0L);
  152.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  153.                         &theRect, &dest, 0, 0L);
  154.                 theRect.bottom+=BoxSize;
  155.                 theRect.top+=BoxSize;
  156.                 if (everyOther)
  157.                     TimeCorrection(CorrectTime);
  158.                 everyOther=!everyOther;
  159.             }
  160.         }
  161.         else    /* these scroll down */
  162.         {
  163.             scrollsource=bounds[y];
  164.             scrollsource.bottom-=BoxSize;
  165.             scrolldest = scrollsource;
  166.             OffsetRect(&scrolldest, 0, BoxSize);
  167.             
  168.             dest=bounds[y];
  169.             dest.bottom=dest.top+BoxSize;
  170.             
  171.             theRect=bounds[y];
  172.             theRect.top=theRect.bottom-BoxSize;
  173.             
  174.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  175.             {
  176.                 StartTiming();
  177.                 CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  178.                         &scrollsource, &scrolldest, 0, 0L);
  179.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  180.                         &theRect, &dest, 0, 0L);
  181.                 theRect.bottom-=BoxSize;
  182.                 theRect.top-=BoxSize;
  183.                 if (everyOther)
  184.                     TimeCorrection(CorrectTime);
  185.                 everyOther=!everyOther;
  186.             }
  187.         }
  188.         
  189.         CopyBits(&(sourceGrafPtr->portBits),&(destGrafPtr->portBits),
  190.                     &bounds[y],&bounds[y],0,0L);
  191.     }
  192. }
  193.